package com.qyhl.webtv.module_live.teletext.newlivelist;


import android.util.Log;

import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.common.CommonUtils;
import com.qyhl.webtv.commonlib.entity.live.LiveRoomBean;
import com.qyhl.webtv.commonlib.entity.live.NewLiveListBean;
import com.qyhl.webtv.module_live.common.LiveUrl;

public class NewLiveListModel implements NewLiveListContract.NewLiveListModel {
    private NewLiveListPresenter mPresenter;

    NewLiveListModel(NewLiveListPresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public void getDataList() {

        EasyHttp.get(LiveUrl.GET_NEWLIVE_LIST)
                .params("siteId", CommonUtils.getInstance().getSite() + "")
                .params("tagName", CommonUtils.getInstance().getSiteName())
                .execute(new SimpleCallBack<NewLiveListBean>() {
                    @Override
                    public void onError(ApiException e) {
                        mPresenter.setError();
                    }

                    @Override
                    public void onSuccess(NewLiveListBean newLiveListBean) {
                        mPresenter.setDataList(newLiveListBean);
                    }
                });

    }

    @Override
    public void checkCode(String sceneId, String code, LiveRoomBean bean) {
        EasyHttp.post(LiveUrl.GET_TELETEXT_CHECK)
                .params("sceneId", sceneId)
                .params("psw", code)
                .execute(new SimpleCallBack<String>() {
                    @Override
                    public void onError(ApiException e) {
                        mPresenter.checkResult(false, bean);
                    }

                    @Override
                    public void onSuccess(String s) {
                        mPresenter.checkResult(true, bean);
                    }
                });
    }
}
